// components/priceCard/priceCard.js
const { initQiniu, uploadFile } = require("../../utils/ossUtil");
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        // 判断是文件还是照片模块
        typeCard: {
            type: String,
            defult: 'file'
        },
        originFiles: {
            type: Object,
            defult: {}
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        visible:false,
        cur: {},
        position: [
            { value: 'bottom', text: '底部弹出' },
        ],
    },

    /**
     * 组件的方法列表
     */
    methods: {
        // 提交打印
        printEvent(e){
            const { item } = e.currentTarget.dataset;
            this.setData(
              {
                cur: item,
              },
              () => {
                this.setData({ visible: true });
              },
            );
        },
        onVisibleChange(e) {
            this.setData({
              visible: e.detail.visible,
            });
          },
        //   关闭弹窗
        closePopup(){
            this.setData({ visible: false });
        },
        addPhoto(){
            wx.chooseMessageFile({
                success(res){
                    //调用上传接口
                    var filePath = res.tempFiles[0].path;
                    initQiniu()
                    uploadFile(filePath,(res)=>{
                        console.log(res);
                    })
                 }
             })
        },
        // 确认打印
        checkPrint(){
            console.log(this.properties.originFiles);
            this.setData({ visible: false });
        }
    }
})
